<?php
namespace Home\Controller;

use Util\AccessController;

class BookListController extends AccessController {
    public function GetBookList() {
        $files = C('BOOK_LS');
        $_POST['banner_id'] ? $where['ts_booklist_inventory.booklist_id'] = $_POST['banner_id'] : 1;
        $where['ts_book.SXJ'] = 1;
        $LS = Service('BookList', 'booklist_inventory');
        $DATA = $LS->query($where, null, $files, null, "ts_book on ts_book.ID = ts_booklist_inventory.book_id");
        $DATA = ResData($DATA);
        $this->ajaxReturn($DATA, 'JSON');
    }

    /*
     * 获取所有书单的书籍
     */
    public function GetAllBookListBook(){
        $LS = Service('M', 'all_booklist_book_view');
        $DATA = $LS->query();
        $DATA = ResData($DATA);
        $this->ajaxReturn($DATA, 'JSON');
    }

    /*
     * 热门书籍
     */
    public function GetHotBookList() {
        $files = C('BOOK_LS');
        $where['ts_booklist_inventory.booklist_id'] = 'ban_5a2101eaafbfc1';
        $where['ts_book.SXJ'] = 1;
        $LS = Service('BookList', 'booklist_inventory');
        $DATA = $LS->query($where, null, $files, null, "ts_book on ts_book.ID = ts_booklist_inventory.book_id");
        $DATA = ResData($DATA);
        $this->ajaxReturn($DATA, 'JSON');
    }

    /*
     * 新书上架
     */
    public function GetNewBookList() {
        $files = C('BOOK_LS');
        $where['ts_booklist_inventory.booklist_id'] = 'ban_5a1d0fcf0c8782';
        $where['ts_book.SXJ'] = 1;
        $LS = Service('BookList', 'booklist_inventory');
        $DATA = $LS->query($where, null, $files, null, "ts_book on ts_book.ID = ts_booklist_inventory.book_id");
        $DATA = ResData($DATA);
        $this->ajaxReturn($DATA, 'JSON');
    }

    /*
     * 为你推荐
     */
    public function GetRecommendedBookList() {
        $files = C('BOOK_LS');
        $where['ts_booklist_inventory.booklist_id'] = 'ban_5a9f873186ece7';
        $where['ts_book.SXJ'] = 1;
        $LS = Service('BookList', 'booklist_inventory');
        $DATA = $LS->query($where, null, $files, null, "ts_book on ts_book.ID = ts_booklist_inventory.book_id");
        $DATA = ResData($DATA);
        $this->ajaxReturn($DATA, 'JSON');
    }

}